package com.gj.daoImp;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.gj.bean.ContactsBean;
import com.gj.bean.UserBean;
import com.gj.dao.UserDao;
import com.gj.util.SqlHelper;
import com.gj.util.WriteLog;

public class UserDaoImple implements UserDao {
	  SqlHelper sql;
	  /* (non-Javadoc)
	 * @see com.gj.daoImp.UserDao#findUser(java.lang.String)
	 */
	@Override
	public UserBean findUser(String  telephone){
		String sqlSt="select * from user where telephone=?";
		String[] param={telephone};
		ResultSet result=sql.getResultSet(sqlSt,param);
		UserBean  user=new UserBean();
		try {
			while(result.next()){
				
				
				
				user.setUserId(Integer.parseInt(result.getString("userId")));
				user.setTelephone(result.getString("telephone"));
				user.setPassword(result.getString("password"));
				user.setUserRole(Integer.parseInt(result.getString("UserRole")));
			
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			WriteLog.getLog4j().logger.debug(e.getMessage());
		}
		return user;
	}
	
}
